﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;

namespace TerminalServis
{
    /// <summary>
    /// Summary description for Service
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service : System.Web.Services.WebService
    {
        [WebMethod]
        public void AddParameter1(string name, byte sqlType, object value, string sessionID)
        {
            Hafiza.Get(sessionID).AddParams(name, sqlType, value);
        }

        [WebMethod]
        public void ParameterValue(int idx, object value, string sessionID)
        {
            Hafiza.Get(sessionID).ParamsValue(idx, value);
        }

        [WebMethod]
        public void AddParameter2(string name, byte sqlType, object value, int size, string sessionID)
        {
            Hafiza.Get(sessionID).AddParams(name, sqlType, value, size);
        }

        [WebMethod]
        public void Exec(string sqlQuery, string sessionID)
        {
            Hafiza.Get(sessionID).Exec(sqlQuery);
        }

        [WebMethod]
        public void Clear(string sessionID)
        {
            Hafiza.Get(sessionID).Clear();
        }

        [WebMethod]
        public object ExecScalar(string sqlQuery, string sessionID)
        {
            return Hafiza.Get(sessionID).ExecuteScaler(sqlQuery);
        }

        [WebMethod]
        public DataSet Fill(string sqlQuery, string sessionID)
        {
            DataSet ds = new DataSet();
            ds.Tables.Add(Hafiza.Get(sessionID).Fill(sqlQuery));
            return ds;
        }

        [WebMethod]
        public void OpenTran(string sessionID)
        {
            Hafiza.Get(sessionID).OpenTransAction();
        }

        [WebMethod]
        public bool CommitTran(string sessionID)
        {
            return Hafiza.Get(sessionID).CommitTran();
        }
    }
}
